from locust import HttpLocust,TaskSet,task

class Tuya_Live(TaskSet):
    def live_login(self):
        login_url = "https://www-api2.gpmine.com/v2/user/auth/login"
        login_data = {
            "name": "15986673013", "password": "111111"
        }
        login_response = self.client.post(url=login_url, data=login_data,name='登录')
        self.token = login_response.json().get('data').get('auth').get('token')
        print('登录')

    def live_list(self):
        rooms_url = 'https://live-zull-aiccp.xiyizb.com/player/1.0/getAnchorRooms'
        #rooms_headers = {'token': self.token}
        rooms_headers = {'token':'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6InRva2VuIn0.eyJpc3MiOiJ0YzNnYS5jb20iLCJhdWQiOiJ0YzNnYS5jb20iLCJqdGkiOiJ0b2tlbiIsImlhdCI6MTUzOTU5OTQwMSwibmJmIjoxNTM5NTk5NDYxLCJleHAiOjE1NDIxOTE0MDEsInVpZCI6MTE1LCJsb2dpbklkIjoiNWJjNDZjMjkzN2QxNyIsInBsR2lkIjoxLCJ0aW1lIjoxNTM5NTk5NDAxLCJ0cmlhbF9zdGF0dXMiOiIifQ.VH6H0_lIsn0aa8GTtpJI19_J3H2maACn0CRM86EX1Is'}
        self.client.get(url=rooms_url, headers=rooms_headers,name='直播列表')
        print('进入直播列表')

    def live_list1(self):
        rooms_url1 = 'http://lpp.seoliao.com/fsms/266136261704544256_sd.m3u8?auth_key=1541469977-0-0-37d383954d07af02a9e045b9538d8f3c'
        self.client.get(url=rooms_url1,stream=True,name='直播流')



    @task
    def live_run(self):
        #self.live_login()
        #self.live_list()
        self.live_list1()


class Tuya_User(HttpLocust):
    task_set = Tuya_Live
    min_wait = 1000
    max_wait = 3000
    host = ''




